package com.Exception.MyException;
import java.util.ArrayList;
import java.util.List;
public class Register
{
    List<String> usernames = new ArrayList<String>();
    public void init()
    {
        usernames = new ArrayList<String>();
        usernames.add("张三");
        usernames.add("李四");
        usernames.add("王五");

    }
    public void register(String name)
    {
        for (String username : usernames)
            if (name.equals(username))
                throw new RegisterException("亲，该用户名已经被注册");
        usernames.add(name);
        System.out.println("注册成功！");
    }
}
